package com.ruoyi.system.outto.goods.impl;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttrTemplateMapper;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttributeMapper;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoImgMapper;
import com.ruoyi.system.V2.inter.mapper.ArtRecMapper;
import com.ruoyi.system.interAttr.domain.InterAttr;
import com.ruoyi.system.interAttr.mapper.InterAttrMapper;
import com.ruoyi.system.model.domain.*;
import com.ruoyi.system.model.dto.GoodsInfoAndAttrValueDto;
import com.ruoyi.system.outto.goods.NEWTHGAPI;
import com.ruoyi.system.outto.goods.TAOHAOYAAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/5 16:19
 */
@Slf4j
@Service
public class TAOHAOYAAPIImpl implements TAOHAOYAAPI {

    @Resource
    private GameAttrTemplateMapper gameAttrTemplateMapper;
    @Resource
    private GameAttributeMapper gameAttributeMapper;
    @Resource
    private GoodsInfoImgMapper goodsInfoImgMapper;
    @Resource
    private ArtRecMapper artRecMapper;
    @Resource
    InterAttrMapper interAttrMapper;

    @Override
    public AjaxResult addGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, "add", salePartner);
        Map<String, Object> result = new HashMap<>();

        String response = HttpRequest.post("https://api.taohaoyayy.com/v1/goods/edit").header("Authorization" , "Bearer "+salePartner.getTwoOther())
                .body(JSONObject.toJSONString(params)).execute().body();

        log.info("淘号鸭添加接口请求参数={}", JSONObject.toJSONString(params));
        log.info("淘号鸭添加接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)) {
            if (!"0".equals(resultJson.getString("code"))) {
                result.put("code", 500);
            } else {
                result.put("code", 200);
                String data = JSONObject.parseObject(response).getString("data");
                String code = JSONObject.parseObject(data).getString("code");
                result.put("outId", code);
            }
            result.put("msg", resultJson.getString("msg"));
        } else {
            result.put("code", 500);
            result.put("msg", "添加失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, "add", salePartner);
        Map<String, Object> result = new HashMap<>();

        String response = HttpRequest.post("https://api.taohaoyayy.com/v1/goods/edit").header("Authorization" , "Bearer "+salePartner.getTwoOther())
                .body(JSONObject.toJSONString(params)).execute().body();

        log.info("淘号鸭编辑接口请求参数={}", JSONObject.toJSONString(params));
        log.info("淘号鸭编辑接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)) {
            if (!"0".equals(resultJson.getString("code"))) {
                result.put("code", 500);
            } else {
                result.put("code", 200);
                String data = JSONObject.parseObject(response).getString("data");
                String code = JSONObject.parseObject(data).getString("code");
                result.put("outId", code);
            }
            result.put("msg", resultJson.getString("msg"));
        } else {
            result.put("code", 500);
            result.put("msg", "添加失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }

    private void builderServer(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, Map params, String server) {
        //========================开始匹配区服属性=====================//
        JSONObject jsonObject = JSONObject.parseObject(server);
        //开始匹配一级区服
        String interServeReqs = jsonObject.getString("interServeReqs");
        String qufuid = "";
        if (Objects.equals(goodsInfoAndAttrValueDto.getGameType(), "0")) {
            qufuid = goodsInfoAndAttrValueDto.getSystemId() + "" + goodsInfoAndAttrValueDto.getCarrierId() + "";
            List<JSONObject> oneServer = JSONObject.parseArray(interServeReqs, JSONObject.class);
            for (JSONObject object : oneServer) {
                String ydServeId = object.getString("YdServeId");
                if (StringUtils.isNotEmpty(ydServeId)) {
                    ydServeId = ydServeId.replace(",", "").replace(" ", "");
                    if (qufuid.contains(ydServeId)) {
                        params.put("area", object.getString("name"));
                        params.put("optionIds", object.getString("id"));
                        break;
                    }
                }
            }
        } else {
            qufuid = goodsInfoAndAttrValueDto.getServerId() + "";
            List<JSONObject> oneServer = JSONObject.parseArray(interServeReqs, JSONObject.class);
            for (JSONObject object : oneServer) {
                String ydServeId = object.getString("YdServeId");
                if (StringUtils.isNotEmpty(ydServeId)) {
                    String interServerRes = object.getString("interServerRes");
                    List<JSONObject> oneServers = JSONObject.parseArray(interServerRes, JSONObject.class);
                    for (JSONObject objects : oneServers) {
                        ydServeId = objects.getString("YdServeId");
                        if(StringUtils.isNotEmpty(ydServeId)) {
                            ydServeId = ydServeId.replace(",", "").replace(" ", "");
                            if (Objects.equals(qufuid, ydServeId)) {
                                params.put("area", objects.getString("name"));
                                break;
                            }
                        }
                    }
                }
            }
        }
    }

    /**
     * 开始匹配单选属性
     *
     * @param goodsInfoAndAttrValueDto
     * @param radioAttr
     */
    private void builderRadioAttr(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, String radioAttr, JSONArray valueList) {
        //========================开始匹配单选属性=====================//
        JSONObject jsonObject = JSONObject.parseObject(radioAttr);
        String interRadioReqs = jsonObject.getString("interRadioReqs");
        log.info(JSONObject.toJSONString(interRadioReqs));
        List<JSONObject> jsonObjects = JSONObject.parseArray(interRadioReqs, JSONObject.class);
        if (org.springframework.util.CollectionUtils.isEmpty(jsonObjects)) {
            throw new GlobalException("接口单选属性暂未配置");
        }
        /**
         * 1、先查询自定义中所有单选的字段
         * 2、再查该账号单选字段中的选项
         * 3、再去接口属性匹配表过滤
         */
        GameAttrTemplate gameAttrTemplate = new GameAttrTemplate();
        gameAttrTemplate.setGameId(goodsInfoAndAttrValueDto.getGameId());
        gameAttrTemplate.setIsEnable("0");
        gameAttrTemplate.setFieldType("radio");
        List<GameAttrTemplate> gameAttrTemplates = gameAttrTemplateMapper.selectGameAttrTemplateList(gameAttrTemplate);
        Field[] declaredFields = goodsInfoAndAttrValueDto.getClass().getDeclaredFields();


        List<JSONObject> defObjects = new ArrayList<>();
        defObjects.addAll(jsonObjects);
        for (JSONObject object : jsonObjects) {
            JSONObject att = new JSONObject();
            for (GameAttrTemplate attrTemplate : gameAttrTemplates) {
                String aavName = attrTemplate.getAavName();
                for (Field declaredField : declaredFields) {
                    String name = declaredField.getName();
                    if (aavName.equals(name)) {
                        //一级属性
                        //注意 YdConfigId 对应的是 f字段对应的 id
                        if (Objects.equals(object.getLong("YdConfigId"), attrTemplate.getId())) {
                            defObjects.remove(object);//如果匹配上，则去掉
                            String interRadioReqs1 = object.getString("interRadioReqs");
                            List<JSONObject> jsonObjects2 = JSONObject.parseArray(interRadioReqs1, JSONObject.class);
                            declaredField.setAccessible(true);
                            try {
                                //获取选择的值 例如  实名中的可二次
                                Object o = declaredField.get(goodsInfoAndAttrValueDto);
                                String oneValue = String.valueOf(o);
                                List<JSONObject> twoAttr = jsonObjects2.stream().filter(j -> StringUtils.isNotEmpty(j.getString("YdConfigId"))?j.getString("YdConfigId").contains(oneValue):"111".contains(oneValue)).collect(Collectors.toList());
                                if (!org.springframework.util.CollectionUtils.isEmpty(twoAttr)) {
                                    JSONObject jsonObject2 = twoAttr.get(0);
                                    String interConfigId2 = jsonObject2.getString("name");
                                    att.put("configId", object.getInteger("id"));
                                    att.put("configName", object.getString("name").split("-")[0]);
                                    att.put("mappingField", object.getString("name").split("-")[1]);
                                    att.put("type", "single");
                                    att.put("val", interConfigId2);
                                    valueList.add(att);
                                }else {
                                    JSONObject jsonObject1 = jsonObjects2.get(0);
                                    att.put("configId", object.getInteger("id"));
                                    att.put("configName", object.getString("name").split("-")[0]);
                                    att.put("mappingField", object.getString("name").split("-")[1]);
                                    att.put("type", "single");
                                    att.put("val", jsonObject1.getString("name"));
                                    valueList.add(att);
                                }
                            } catch (Exception e) {
                                throw new GlobalException("单选项" + attrTemplate.getFieldName() + "匹配错误");
                            }
                        }
                    }
                }
            }
        }
        //开始匹配默认值
        for (JSONObject object : defObjects) {
            JSONObject att = new JSONObject();
            interRadioReqs = object.getString("interRadioReqs");
            jsonObjects = JSONObject.parseArray(interRadioReqs, JSONObject.class);
            for (JSONObject objects : jsonObjects) {
                if(StringUtils.isNotEmpty(objects.getString("defaultValue"))){
                    att.put("configId", object.getInteger("id"));
                    att.put("configName", object.getString("name").split("-")[0]);
                    att.put("mappingField", object.getString("name").split("-")[1]);
                    att.put("type", "single");
                    att.put("val", objects.getString("name"));
                    valueList.add(att);
                }
            }
        }
        //========================单选属性匹配结束=====================//
    }

    private void builderInputAttr(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, String inputAttr, JSONArray valueList) {
//        JSONArray propertys = Objects.isNull(params.get("property")) ? new JSONArray() : JSONArray.parseArray(params.get("property").toString());
        Field[] declaredFields = goodsInfoAndAttrValueDto.getClass().getDeclaredFields();

        //========================开始匹配输入框=====================//
        JSONObject jsonObject1 = JSONObject.parseObject(inputAttr);
        String inputJson = jsonObject1.getString("inputJson");
        List<JSONObject> jsonObjects1 = JSONObject.parseArray(inputJson, JSONObject.class);
        GameAttrTemplate gameAttrTemplate = new GameAttrTemplate();
        gameAttrTemplate.setGameId(goodsInfoAndAttrValueDto.getGameId());
        gameAttrTemplate.setIsEnable("0");
        ArrayList types = new ArrayList<>();
        types.add("number");
        types.add("input");
        gameAttrTemplate.setFieldTypes(types);
        List<GameAttrTemplate> inputTemplates = gameAttrTemplateMapper.selectGameAttrTemplateList(gameAttrTemplate);
        List<JSONObject> defInputObjects = new ArrayList<>();
        defInputObjects.addAll(jsonObjects1);

        for (JSONObject object : jsonObjects1) {
            JSONObject attr = new JSONObject();
            for (GameAttrTemplate inputTemplate : inputTemplates) {
                String aavName = inputTemplate.getAavName();
                if (Objects.equals(object.getString("aavName"), inputTemplate.getAavName())) {
                    defInputObjects.remove(object);
                    String interId = object.getString("interId");
                    for (Field declaredField : declaredFields) {
                        String name = declaredField.getName();
                        if (Objects.equals(aavName, name)) {
                            declaredField.setAccessible(true);
                            Object o = null;
                            try {
                                o = declaredField.get(goodsInfoAndAttrValueDto);
                            } catch (IllegalAccessException e) {
                                throw new GlobalException("3属性参数错误，请匹配后重新配置");
                            }
                            String oneValue = String.valueOf(o);
                            if (StringUtils.isNotEmpty(oneValue)) {
                                attr.put("configId", object.getInteger("id"));
                                attr.put("configName", object.getString("name").split("-")[0]);
                                attr.put("mappingField", object.getString("name").split("-")[1]);
                                attr.put("type", "single");
                                attr.put("val", oneValue);
                                valueList.add(attr);
                            }
                        }
                    }
                }
            }
        }
        //开始匹配默认值
        for (JSONObject object : defInputObjects) {
            JSONObject attr = new JSONObject();
            attr.put("configId", object.getInteger("id"));
            attr.put("configName", object.getString("name").split("-")[0]);
            attr.put("mappingField", object.getString("name").split("-")[1]);
            String defaultValue = object.getString("defaultValue");
            if (StringUtils.isNotEmpty(defaultValue)) {
                if(object.getString("name").contains("标题")){
                    attr.put("type", "input");
                    attr.put("val", goodsInfoAndAttrValueDto.getTitle());
                }else if(object.getString("name").contains("描述")){
                    attr.put("type", "text");
                    attr.put("val", goodsInfoAndAttrValueDto.getDes());
                }else if(object.getString("name").contains("价格")){
                    attr.put("type", "float2");
                    attr.put("val", goodsInfoAndAttrValueDto.getPrice().toPlainString());
                }else if(object.getString("name").contains("封面图片")){
                    attr.put("type", "image");
                    attr.put("val", goodsInfoAndAttrValueDto.getTitleImg());
                }else if(object.getString("name").contains("详情图片")){
                    attr.put("type", "image");
                    List<Map<String, Object>> urlArr = goodsInfoAndAttrValueDto.getUrlArr();
                    StringBuffer imgs = new StringBuffer();
                    for(Map<String, Object> maps : urlArr){
                        String ss = String.valueOf(maps.get("url"));
                        String imgStr = ss + ",";
                        imgs.append(imgStr);
                    }
                    String imgUrls = imgs.toString().substring(0, imgs.length() - 1);
                    attr.put("val", imgUrls);
                }
            }
            valueList.add(attr);
        }

    }

    private void builderCheckAttr(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, String checkAttr, JSONArray valueList) {
        /**
         * 1、先查询自定义中所有多选的字段
         * 2、再查该账号单选字段中的选项
         * 3、再去接口属性匹配表过滤
         */
        Field[] declaredFields = goodsInfoAndAttrValueDto.getClass().getDeclaredFields();
        JSONObject checkAttrJson = JSONObject.parseObject(checkAttr);
        String interCheckBoxReqs = checkAttrJson.getString("interCheckBoxReqs");
        List<JSONObject> checkJsonList = JSONObject.parseArray(interCheckBoxReqs, JSONObject.class);
        if (org.springframework.util.CollectionUtils.isEmpty(checkAttrJson)) {
            throw new GlobalException("接口多选属性暂未配置");
        }

        GameAttrTemplate gameAttrTemplate = new GameAttrTemplate();
        gameAttrTemplate.setGameId(goodsInfoAndAttrValueDto.getGameId());
        gameAttrTemplate.setIsEnable("0");
        List<String> types = new ArrayList<>();
        types.add("checkbox");
        types.add("boxradio");
        gameAttrTemplate.setFieldTypes(types);
        List<GameAttrTemplate> checkAttrTemplates = gameAttrTemplateMapper.selectGameAttrTemplateList(gameAttrTemplate);

        for (JSONObject object : checkJsonList) {
            JSONObject attr = new JSONObject();
            String pf_ids = "";
            for (GameAttrTemplate attrTemplate : checkAttrTemplates) {

                String aavName = attrTemplate.getAavName();
                for (Field declaredField : declaredFields) {
                    String name = declaredField.getName();
                    if (aavName.equals(name)) {
                        declaredField.setAccessible(true);

//                        List<String> list2 = new ArrayList<>();
//                        for (String s : split2) {
//                            s = s.replace(" ", "");
//                            list2.add(s);
//                        }
                        Object o = null;
                        try {
                            o = declaredField.get(goodsInfoAndAttrValueDto);
                        } catch (IllegalAccessException e) {
                            throw new GlobalException("多选项" + attrTemplate.getFieldName() + "匹配错误");
                        }
                        String oneValue = String.valueOf(o);
                        String interCheckBoxReqsStr = object.getString("interCheckBoxReqs");
                        //开始匹配二级属性
                        List<JSONObject> jsonObjects2 = JSONObject.parseArray(interCheckBoxReqsStr, JSONObject.class);
                        /**
                         * 咱们的f字段  多选项都是用空格 隔开，用,号切割数组，跟匹配的数据匹配、匹配上说明此账号勾选的有此属性
                         */
                        for (JSONObject jsonObject1 : jsonObjects2) {
                            String[] split1 = oneValue.split(",");
                            String ydConfigId1 = jsonObject1.getString("YdConfigId");
                            if(StringUtils.isNotEmpty(ydConfigId1)){
                                ydConfigId1 = ydConfigId1.replace(" ","");
                            }
                            for (String s : split1) {
                                if (Objects.equals(s, ydConfigId1)) {
                                    String InterConfigId2 = jsonObject1.getString("id");
                                    pf_ids+=","+InterConfigId2;
                                }
                            }
                        }

                    }
                }
            }
            if (StringUtils.isNotEmpty(pf_ids)) {
                attr.put("configId", object.getInteger("id"));
                attr.put("configName", object.getString("name").split("-")[0]);
                attr.put("mappingField", object.getString("name").split("-")[1]);
                attr.put("type", "checkbox");
                attr.put("val", pf_ids.substring(1));
                valueList.add(attr);
            }
        }
    }

    private Map<String, Object> params(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, String type, SalePartner salePartner) {
        Map<String, Object> params = new HashMap<>();
        String substring = salePartner.getSaleName().substring(salePartner.getSaleName().indexOf("_")+1);
        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(substring, goodsInfoAndAttrValueDto.getGameId());
        //区服
        builderServer(goodsInfoAndAttrValueDto, params, interAttr.getServer());
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(salePartner.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        if(CollectionUtils.isNotEmpty(artRecs)) {
            params.put("code" , artRecs.get(0).getOutid());
        }

        params.put("gameId", Integer.parseInt(interAttr.getInterGameId()));
        JSONArray configInfo = new JSONArray();
        //开始匹配单选属性
        builderRadioAttr(goodsInfoAndAttrValueDto, interAttr.getRadioAttr(),configInfo);
        //开始匹配多选属性
        builderCheckAttr(goodsInfoAndAttrValueDto, interAttr.getCheckAttr(),configInfo);

        //开始匹配输入框属性
        builderInputAttr(goodsInfoAndAttrValueDto, interAttr.getInputAttr(),configInfo);
        params.put("configInfo", configInfo);
        return params;
    }

    @Override
    public AjaxResult delGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        Map<String, Object> params = new HashMap<>();
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(salePartner.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        if(CollectionUtils.isNotEmpty(artRecs)) {
            params.put("code" , artRecs.get(0).getOutid());
        }
        Map<String, Object> result = new HashMap<>();

        String response = HttpRequest.post("https://api.taohaoyayy.com/v1/goods/off-sale").header("Authorization" , "Bearer "+salePartner.getTwoOther())
                .body(JSONObject.toJSONString(params)).execute().body();
        log.info("淘号鸭下架接口请求参数={}", JSONObject.toJSONString(params));
        log.info("淘号鸭下架接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)) {
            if (!"0".equals(resultJson.getString("code"))) {
                result.put("code", 500);
            } else {
                result.put("code", 200);
                String authorization = HttpRequest.post("https://api.taohaoyayy.com/v1/goods/delete").header("Authorization" , "Bearer " + salePartner.getTwoOther())
                        .body(JSONObject.toJSONString(params)).execute().body();
            }
            result.put("msg", resultJson.getString("msg"));
        } else {
            result.put("code", 500);
            result.put("msg", "添加失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }

    public static void main(String[] args) {

        Map<String,Object> params = new HashMap<>();
        params.put("apiKey","0McKSOMjak1kCjGzFZOdXLFYQs98WN1U");
        params.put("secretKey","rH7QLdAk2TFO14AEUrgOy7DqFWKykCIXonSkYFpOsCY03gQspzMX7JMxvtZ2kVLu");
        String response = HttpRequest.post("https://api.taohaoyayy.com/v1/user/access-token").body(JSONObject.toJSONString(params)).execute().body();
        String data = JSONObject.parseObject(response).getString("data");
        String accessToken = JSONObject.parseObject(data).getString("accessToken");
        log.info(accessToken);
    }

    public static String kuozhanshuxing(int type, SalePartner salePartner) {
        Map<String, Object> params1 = new TreeMap<>();
        Map<String, Object> head = new HashMap<>();
        head.put("content-type", "application/x-www-form-urlencoded");
        params1.put("key", salePartner.getSaleKey());
        params1.put("merchant_no", salePartner.getTwoOther());
        params1.put("gameid", type);
        params1.put("content-type", "application/x-www-form-urlencoded");
        String response = HttpUtils.doPostForm(salePartner.getOther() + "/getExpendAttribute.ashx", params1, head);
        if(StringUtils.isEmpty(response)){
            throw new GlobalException("获取淘号鸭属性失败!!!");
        }
        JSONObject resultJson = JSONObject.parseObject(response);
        if(!"true".equals(resultJson.getString("succ"))){
            throw new GlobalException(response);
        }
        return response;
    }

    public static String youxiqufu(int type, SalePartner salePartner) {
        Map<String, Object> params1 = new TreeMap<>();
        Map<String, Object> head = new HashMap<>();
        head.put("content-type", "application/x-www-form-urlencoded");
        params1.put("key", salePartner.getSaleKey());
        params1.put("merchant_no", salePartner.getTwoOther());
        params1.put("gameid", type);
        params1.put("content-type", "application/x-www-form-urlencoded");
        String URL = salePartner.getOther() + "/getAreaServer.ashx";
        String response = HttpUtils.doPostForm(URL, params1, head);
        if(StringUtils.isEmpty(response)){
            throw new GlobalException("获取淘号鸭区服失败!!!");
        }
        JSONObject resultJson = JSONObject.parseObject(response);
        if(!"true".equals(resultJson.getString("succ"))){
            throw new GlobalException(response);
        }
        return response;
    }

    public static String games(SalePartner salePartner) {
        Map<String, Object> params1 = new TreeMap<>();
        Map<String, Object> head = new HashMap<>();
        head.put("content-type", "application/x-www-form-urlencoded");
        params1.put("key", salePartner.getSaleKey());
        params1.put("merchant_no", salePartner.getTwoOther());
        params1.put("content-type", "application/x-www-form-urlencoded");
        String response = HttpUtils.doPostForm(salePartner.getOther() + "/getGameInfor.ashx", params1, head);
        if(StringUtils.isEmpty(response)){
            throw new GlobalException("获取淘号鸭游戏失败!!!");
        }
        JSONObject resultJson = JSONObject.parseObject(response);
        if(!"true".equals(resultJson.getString("succ"))){
            throw new GlobalException(response);
        }
        return response;
    }

    public static String getGameID(String gameName, SalePartner salePartner) {
        String response = games(salePartner);
        String data = JSONObject.parseObject(response).getString("data");
        return null;
    }

}
